package com.matt.order.controller;

import com.matt.order.dto.CustomerDto;
import com.matt.order.service.CustomerEnterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/customerList")
public class CustomerListController {
    @Autowired
    CustomerEnterService customerEnterService;

    @RequestMapping("/init")
    public String customerListInit(Model model) {
        List<CustomerDto> customerList = customerEnterService.customerInfoList();
        List<CustomerDto> customerGenderSUMInfoList = customerEnterService.customerGenderSUMInfoList();
        List<CustomerDto> customerSourceSUMInfoList = customerEnterService.customerSourceSUMInfoList();
        String customerPaySumInfo = customerEnterService.customerPaySumInfo();
        model.addAttribute("customerList", customerList);
        model.addAttribute("customerGenderSUMInfoList", customerGenderSUMInfoList);
        model.addAttribute("customerSourceSUMInfoList", customerSourceSUMInfoList);
        model.addAttribute("customerPaySumInfo", customerPaySumInfo);
        return "order/customer-list";
    }
}
